public class Java18 {
    public static void main(String[] args) {
        //输出1-5的自然数
        int i = 1;
        while (i <= 5) {
            System.out.println(i);
            i = i + 1;
        }
        i = 1;
        do {
            System.out.println(i);
            i = i + 1;
        } while (i <= 5);
        for (int j = 1; j <= 5; j++) {
            System.out.println(j);
        }
        //计算1-50之间和（使用循环计算）
        int total = 0;
        int a = 1;
        while (a <= 50) {
            total = total + a;
            a++;
        }
        System.out.print("while循坏得出的结果：" + total);
        total = 0;
        a = 1;
        do {
            total = total + a;
            a++;
        } while (a <= 50);
        System.out.print("do循坏得出的结果：" + total);
        total = 0;
        for (int j = 1; j <= 50; j++) total = total + j;
        System.out.print("for循坏得出的结果：" + total);
    }
}
